/**************************************************************************
File:        positioner.h
Description:
 
Copyright:   (C) 2001-2012 by ZJ Laczik
Email:       Zsolt.Laczik@eng.ox.ac.uk
****************************************************************************
Change log:
   begin      Mon Mar 19 2001
   15/2/2012	QT4 update
***************************************************************************/


#ifndef POSITIONER_H
#define POSITIONER_H

#include <QObject>
#include <QWidget>
#include <QString>

#include "qextserialport.h"

#include "stepper.h"

//class Stepper;

/**
  *@author ZJ Laczik
  */

class Positioner : public QObject  {
   Q_OBJECT
public: 
	Positioner(QWidget *parent=0);
	~Positioner();
public slots:
	void Stop();
	void MoveTo(float x, float y, float z);
	void Move(int axis, float pos);
	void MoveXTo(float pos);
	void MoveYTo(float pos);
	void MoveZTo(float pos);
	void Shoot(bool & success);
	void WarningSign(bool & success, bool on);
	void InterLockOK(bool & success);
signals:
	void StatusMsg(const QString & message, bool);
	void Position(float x, float y, float z);
	void Running(bool state);
public:
	Stepper stepper ;
private:
	int mType;
	QextSerialPort *mSerPort;
	float mX,mY,mZ;
	bool mStopFlag;
	int mStepRate;
private: // Private methods
	bool PPMoveTo(float x, float y, float z);
	bool IP28Init();
	void IP28Shutdown();
	bool IP28MoveTo(float x, float y, float z);
	bool IP28ReadPosition(int &x, int &y, int &z, int &fx, int &fy, int &fz);
	bool IP28SendCmd(QString cmd, QString & response, bool wait=true, int timeout=1000);
	bool DummyInit();
};

#endif
